<?php

include_once 'dbtable.php';


function get_all_album(pager $page,$url) {
    $sql = "select album.*,user.* from album,user where album.user_id = user.id    
and album.status = 1";
    return DbTable::Paging($page, $sql, $url,50);
}
function them_moi_album($array) {
    if (DbTable::insert("album", $array)) {
        return true;
    }
    return false;
}

function sua_album($array, $id) {
    if (DbTable::update("album", $array, $id)) {
        return true;
    }
    return false;
}
function xoa_album($id) {
    if(DbTable::delete("album", $id)){
        return true;
    }
    return false;
}
//lay anh radom
function get_random_image() {
    $sql = "select album.*,user.* from album,user where user.id = album.user_id order by rand() limit 0,10";
    return DbTable::getData($sql);
}
//lay anh moi nhat
function get_image_new() {
    $sql = "select album.*,user.* from album,user where user.id = album.user_id order by album.date_upload desc limit 0,5";
    return DbTable::getData($sql);
}
//lay ten hinh anh theo id
function get_name_image_by_id($id) {
    $sql = "select image_name from album where id='{$id}'";
    return DbTable::Single($sql);
}
?>
